//
//  YWAskView.m
//  jijinApp
//
//  Created by yellow on 2021/11/9.
//

#import "YWAskView.h"

@interface YWAskView ()
@property (weak, nonatomic) IBOutlet UIButton *blackBtn;
- (IBAction)blackBtnClick:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet UIView *textBgView;
@property (weak, nonatomic) IBOutlet UILabel *textLabel;
//@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textLabelHeightConstraint;

@end

@implementation YWAskView



-(void)awakeFromNib{
    
    [super awakeFromNib];
    
    self.textBgView.layer.cornerRadius = 8;
    self.textBgView.clipsToBounds = YES;
    
    self.textLabel.numberOfLines = 0;
    
}

+(instancetype)askView{
    
    YWAskView *view = [[NSBundle mainBundle] loadNibNamed:@"YWAskView" owner:nil options:nil].firstObject;
    
    return view;
    
}

-(void)setFont:(NSInteger)font{
    _font = font;
    self.textLabel.font = [UIFont systemFontOfSize:font];
}

-(void)setTitle:(NSString *)title{
    _title = [title copy];
    
    self.textLabel.text = title;
}



-(void)show{
    
    self.alpha = 0;
    
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
    self.frame = CGRectMake(0, 0, Wi, He);
    
    
    [UIView animateWithDuration:0.2 animations:^{
        
        self.alpha = 1;
    }];
    
    
}

-(void)cancel{
    
    
    [UIView animateWithDuration:0.2 animations:^{
        
        self.alpha = 0;
        
    }completion:^(BOOL finished) {
        
        [self removeFromSuperview];
        
    }];
}


- (IBAction)blackBtnClick:(UIButton *)sender {
    
    [self cancel];
}
@end
